// 订单模型
const { Role, validateRole } = require('../../../models/role');
// // 权限模型
// const { AuthOne, AuthTwo, AuthThree } = require('../../../models/auth');
// 统一数据返回类
const { DataReturn } = require('../../../common/returnclass');

/**
 * @api {Get} /menus 查询后台菜单
 * @apiGroup Admin-Menus
 *
 * @apiParam {String} roleName 角色名称
 *
 * @apiSuccess {ObjectId} _id 权限id
 * @apiSuccess {String} authName 权限名称
 * @apiSuccess {String} icon  图标
 * @apiSuccess {Number} level  权限等级
 * @apiSuccess {String} path  权限路径
 * @apiSuccess {Array} children  子权限
 */
module.exports = async (req, res) => {
	// 身份类型
	let { roleName } = req.query;
	console.log(roleName);
	
	let menus = await Role.findOne({ roleName });
	console.log(menus)
	if (!menus) return DataReturn.getData(res, 200, [], '获取菜单数据失败');
	DataReturn.getData(res, 200, menus.children, '获取菜单数据成功')
	
	// 查询所有权限信息
	// let auths = await AuthOne.find().populate({
	// 	path: 'children', model: AuthTwo 
	// });
	// if (!auths) return DataReturn.getData(res, 200, [], '获取角色列表失败');
	// // 响应
	// DataReturn.getData(res, 200, auths, '获取权限列表成功')
	

}
